<template>
  <view class="al">
    <form @submit="formSubmit" @reset="formReset">
		<view class="for">
			<view class="content">
				<label class="lable">*电炉铁水标准碳含量%:</label>
				<!-- <input class="number" type="text" v-model="form.tsCbz" placeholder="请输入.." /> -->
				<text class="number" type="number" >{{form.tsCbz}}</text>
			</view> 
			
			<view class="content">
				<label class="lable">低碳废钢碳含量%:</label>
				<input class="number"   type="text" v-model="form.fgCbz" placeholder="请输入.." />
			</view>
		</view>
      
      <button form-type="submit" class="btn" style="bottom: 20px;">提交</button>
    </form>
  </view>
</template>

<script>
import configService from "@/common/config.service.js";
const apiUrl = configService.apiUrl;
export default {
  data() {
    return {
      form: {
        tsCbz:"",
        fgCbz:"",
      },
    };
  },
  mounted() {
    this.getdata();
  },
  onShow:function(e){
  	this.$verify.verify();
  },
  methods: {
    // 页面加载调取数据
    getdata() {
      uni.request({
        url: apiUrl + "/jtss/list",
        header: {
          "content-type": "application/json", //自定义请求头信息
        },
        method: "POST",
        data: {
          type: 1,
		   deptId : uni.getStorageSync("deptId")
        },
        success: (res) => {
			console.log(res);
			if(!res.data || res.data.data.length == 0){
				return;
			}
     
          this.form = res.data.data[0];
          if (res.statusCode === 200) {
            self.Info = res.data;
            //返回数据
          }
        },
      });
    },
    // 数据更改-提交
    formSubmit() {
		var _this = this;
		console.log(_this.form);
		if((this.form.tsCbz === null || "") || (this.form.fgCbz === null || "")){
					  uni.showToast({
					  	title: '表单数据不能为空',
					  	//将值设置为 success 或者直接不用写icon这个参数
					  	// icon: 'success',
					  	//显示持续时间为 2秒
					  	duration: 2000
					  })  
		}else{
			uni.request({
			  url: apiUrl + "/jtss/edit",
			  method: "POST", //请求方式，必须为大写
			  header: {
			    "Content-Type": "application/json", //自定义请求头信息
			  },
			  data : {..._this.form,...{deptId:uni.getStorageSync("deptId"),type: 1}},
			  success: (res) => {
			            if (res.statusCode == 200) {
			              uni.showToast({
			                title: "成功",
			                icon: "success",
			                duration: 1500,
			              });
			              setTimeout(() => {
			                uni.redirectTo({
			                  url: "/pages/dlplss/dlplss",
			                });
			              }, 1000);
			            } else {
			              uni.showToast({
			                title: res.data.message || "获取用户信息失败",
			                icon: "none",
			                duration: 1500,
			              });
			            }
			          },
			});
		}
      
    },
  },
};
</script>

<style>
	@import url("@/common/comcssw.css");
</style>
